package com.yang.leather.admin.schedule;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.yang.leather.admin.dao.IImgsDelDao;
import com.yang.leather.admin.pojo.ImgsDel;
import com.yang.leather.common.upload.IUploadService;
import com.yang.leather.common.util.ComUtils;

/**
 * 服务器图片删除。每天凌晨4:00 执行
 */
@Service("imgDelCronJob")
public class ImgDelQuartzJob implements ImgDelQuartzJobService {
	private static final Logger log = LoggerFactory.getLogger(ImgDelQuartzJob.class);
	
	protected IUploadService uploadService;
	protected IImgsDelDao imgsDelDao;

	public void execute() {
		String endTime = ComUtils.dataFormatWhole(new Date());
		List<ImgsDel> list = getDelImgs(endTime);
		
		if(list!=null && list.size()>0){
			String result = uploadService.deleteFile(list);
			
			if("success".equals(result)){
				delImgs(endTime);
			}
		}
	}

	private List<ImgsDel> getDelImgs(String endTime){

		return null;
	}
	
	private void delImgs(String endTime){
		try{
			
			
		}catch(Exception e){
			log.error(e.getMessage(),e);
		}
	}

	public IUploadService getUploadService() {
		return uploadService;
	}

	@Autowired
	public void setUploadService(@Qualifier("uploadService")
			IUploadService uploadService) {
		this.uploadService = uploadService;
	}

	public IImgsDelDao getImgsDelDao() {
		return imgsDelDao;
	}

	@Autowired
	public void setImgsDelDao(@Qualifier("imgsDelDao")
			IImgsDelDao imgsDelDao) {
		this.imgsDelDao = imgsDelDao;
	}
}
